package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsQy;
import com.ruoyi.yqhs.service.IYqhsQyService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 区域信息Controller
 *
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/qy")
public class YqhsQyController extends BaseController
{
    @Autowired
    private IYqhsQyService yqhsQyService;

    /**
     * 查询区域信息列表
     */
//    @PreAuthorize("@ss.hasPermi('yqhs:qy:list')")
    @GetMapping("/list")
    public AjaxResult list(YqhsQy yqhsQy)
    {
        List<YqhsQy> list = yqhsQyService.selectYqhsQyList(yqhsQy);
        return success(list);
    }

    /**
     * 导出区域信息列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qy:export')")
    @Log(title = "区域信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsQy yqhsQy)
    {
        List<YqhsQy> list = yqhsQyService.selectYqhsQyList(yqhsQy);
        ExcelUtil<YqhsQy> util = new ExcelUtil<YqhsQy>(YqhsQy.class);
        util.exportExcel(response, list, "区域信息数据");
    }

    /**
     * 获取区域信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsQyService.selectYqhsQyById(id));
    }

    /**
     * 新增区域信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qy:add')")
    @Log(title = "区域信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsQy yqhsQy)
    {
        return toAjax(yqhsQyService.insertYqhsQy(yqhsQy));
    }

    /**
     * 修改区域信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qy:edit')")
    @Log(title = "区域信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsQy yqhsQy)
    {
        return toAjax(yqhsQyService.updateYqhsQy(yqhsQy));
    }

    /**
     * 删除区域信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:qy:remove')")
    @Log(title = "区域信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsQyService.deleteYqhsQyByIds(ids));
    }
}
